home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ian & Stuart's Australian Mac 1993 September
/
clonecd
/
September 93.img
/
Archives
/
Utilities
/
Quicktime
/
SLINK's VCR QuickTime
/
MP Source
/
myQuickTime.c
< prev
next >
Wrap
Text File
|
1992-06-15
|
9KB
|
372 lines
/*---------------------------------------------------------------------
File: myQuickTime.c
Purpose: Contains stuff to manage quicktime stuff such as openning
files, setting rates, and such.
Created by: Geoffrey Slinker
Date: 10:58:03 AM 6/13/92
Modified:
---------------------------------------------------------------------*/
#include <GestaltEqu.h>
#include <Movies.h>
#include <MoviesFormat.h>
#include <FixMath.h>
#include <oops.h>
#include "myQuickTime.h"
#include "Alert_Class.h"
#include "Dlog.h"
#include "vcr.h"
extern Alert_Class *myAlert;
extern VCR *vcr;
/*...................................................................*/
void QT::QT()
{
movieWindow = NULL;
moviePosterWindow = NULL;
myMovie = NULL;
}
/*...................................................................*/
void QT::~QT()
{
CWindowPtr movieWindow,moviePosterWindow;
Movie myMovie;
movieWindow = (*this).movieWindow;
moviePosterWindow = (*this).moviePosterWindow;
myMovie = (*this).myMovie;
if (movieWindow != NULL) {
DisposeWindow((WindowPtr)movieWindow);
}
if (moviePosterWindow != NULL) {
DisposeWindow(moviePosterWindow);
}
if (myMovie != NULL) {
DisposeMovie(myMovie);
}
(*this).movieWindow = movieWindow;
(*this).moviePosterWindow = moviePosterWindow;
(*this).myMovie = myMovie;
}
/*...................................................................*/
void QT::MovieCheck()
{
long version;
if (Gestalt( gestaltQuickTime, &version ) != noErr){
(*myAlert).AlertStop("\pFatal Error!",
"\pQuickTime not installed",
"\pPlease Install QuickTime",
"\pSorry.");
}
if(EnterMovies() != noErr) {
(*myAlert).AlertStop("\pFatal Error!",
"\pUnable to Enter Movies",
"\p",
"\pSorry.");
}
}
/*...................................................................*/
void QT::LoadResources()
{
CWindowPtr movieWindow, moviePosterWindow;
movieWindow = (CWindowPtr)GetNewCWindow(MOVIE_WIND,(Ptr)0L,(CWindowPtr)(-1L));
if (movieWindow == NULL) {
SysBeep(7);
(*myAlert).AlertStop("\pFatal Error",
"\pUnable to allocate new color window",
"\pQT::LoadResources",NULL);
}
moviePosterWindow = (CWindowPtr)GetNewCWindow(MOVIE_POSTER_WIND,(Ptr)0L,(CWindowPtr)(-1L));
if (moviePosterWindow == NULL) {
SysBeep(7);
(*myAlert).AlertStop("\pFatal Error",
"\pUnable to allocate new color window",
"\pQT::LoadResources",NULL);
}
(*this).origBounds = (*movieWindow).portRect;
(*this).movieWindow = movieWindow;
(*this).moviePosterWindow = moviePosterWindow;
}
/*...................................................................*/
int QT::OpenMovie()
{
PicHandle poster;
Movie myMovie;
CWindowPtr movieWindow,moviePosterWindow;
StandardFileReply sfr;
SFTypeList types = {'MooV'};
short resRefNum;
short numTypes = 1;
int w,h;
// Shadow variables because the class are handles
// and therefore purgeable.
myMovie = (*this).myMovie;
movieWindow = (*this).movieWindow;
moviePosterWindow = (*this).moviePosterWindow;
StandardGetFilePreview(0, numTypes, types, &sfr);
if (!sfr.sfGood) return(0); /* Return if no selection */
if (OpenMovieFile(&(sfr.sfFile), &resRefNum, 0) != noErr) {
return(0);
}
SetWTitle(movieWindow,sfr.sfFile.name);
if (NewMovieFromFile( &myMovie,resRefNum, nil, nil,0, nil ) != noErr) {
SysBeep(7);
(*myAlert).AlertStop("\pFatal Error",
"\pUnable to get NewMovieFromFile",
"\pQT::OpenMovie",NULL);
}
if (CloseMovieFile( resRefNum ) != noErr) {
SysBeep(7);
(*myAlert).AlertStop("\pFatal Error",
"\pUnable to get CloseMovieFile",
"\pQT::OpenMovie",NULL);
}
/* Get movie box and place movie at 0,0 */
GetMovieBox( myMovie, &dispBounds);
OffsetRect(&dispBounds,-dispBounds.left,-dispBounds.top);
SetMovieBox(myMovie, &dispBounds);
SetPort(movieWindow);
SetMovieGWorld(myMovie,nil,nil);
GoToBeginningOfMovie(myMovie);
PrerollMovie(myMovie,0,0);
SetMovieActive(myMovie,true);
w = dispBounds.right - dispBounds.left;
h = dispBounds.bottom - dispBounds.top;
SizeWindow( (WindowPtr)movieWindow,w,h,true);
SizeWindow( (WindowPtr)moviePosterWindow,w,h,true);
poster = GetMoviePosterPict( myMovie );
if (poster != nil)
{
GrafPtr oldPort;
Rect rect;
GetPort(&oldPort);
SetPort(moviePosterWindow);
rect = (*moviePosterWindow).portRect;
DrawPicture( poster, &rect );
KillPicture( poster );
SetPort(oldPort);
}
(*this).myMovie = myMovie;
return(1);
}
/*...................................................................*/
void QT::PlayMovie()
{
Movie myMovie;
CWindowPtr movieWindow;
myMovie = (*this).myMovie;
movieWindow = (*this).movieWindow;
StartMovie(myMovie);
}
/*...................................................................*/
void QT::CloseMovie()
{
Movie myMovie;
int w,h;
CWindowPtr movieWindow, moviePosterWindow;
GrafPtr oldPort;
Rect origBounds;
GetPort(&oldPort);
myMovie = (*this).myMovie;
if (myMovie != NULL) {
DisposeMovie(myMovie);
}
myMovie = 0; // This has to be here, apparently DisposeMovie didn't set
// the myMovie variable to NULL
(*this).myMovie = myMovie;
movieWindow = (*this).movieWindow;
moviePosterWindow = (*this).moviePosterWindow;
origBounds = (*this).origBounds;
w = origBounds.right - origBounds.left;
h = origBounds.bottom - origBounds.top;
SizeWindow( (WindowPtr)movieWindow,w,h,true);
SizeWindow( (WindowPtr)moviePosterWindow,w,h,true);
SetPort(movieWindow);
SetWTitle(movieWindow, "\pMovie Window");
EraseRect(&origBounds);
SetPort(moviePosterWindow);
EraseRect(&origBounds);
SetPort(oldPort);
(*this).movieWindow = movieWindow;
(*this).moviePosterWindow = moviePosterWindow;
(*vcr).ClearAllButtons();
}
/*...................................................................*/
void QT::MyMoviesTask(void)
{
Movie myMovie;
myMovie = (*this).myMovie;
if (myMovie)
{
MoviesTask(myMovie,0);
if (IsMovieDone(myMovie)) // Have we reached the end yet?
{
if ( (*vcr).vcr_mode == playing) {
GoToBeginningOfMovie( myMovie );
}
else {
(*vcr).ClearAllButtons();
//(*vcr).RedrawButtons();
//GoToBeginningOfMovie( myMovie );
}
}
}
}
/*...................................................................*/
void QT::StopMyMovie(void)
{
Movie myMovie;
myMovie = (*this).myMovie;
if(myMovie != NULL) {
StopMovie( myMovie );
}
(*this).myMovie = myMovie;
}
/*...................................................................*/
void QT::FFMyMovie(void)
{
Movie myMovie;
myMovie = (*this).myMovie;
if (myMovie != NULL) {
SetMovieRate( myMovie, Long2Fix( 2L ) );
}
(*this).myMovie = myMovie;
}
/*...................................................................*/
void QT::RWMyMovie(void)
{
Movie myMovie;
myMovie = (*this).myMovie;
if (myMovie != NULL) {
SetMovieRate( myMovie, Long2Fix( -2L) );
}
(*this).myMovie = myMovie;
}
/*...................................................................*/
void QT::GoStartMyMovie(void)
{
Movie myMovie;
myMovie = (*this).myMovie;
if (myMovie != NULL) {
StopMovie(myMovie);
GoToBeginningOfMovie(myMovie);
}
(*this).myMovie = myMovie;
}
/*...................................................................*/
void QT::GoEndMyMovie(void)
{
Movie myMovie;
myMovie = (*this).myMovie;
if (myMovie != NULL) {
StopMovie(myMovie);
GoToEndOfMovie(myMovie);
}
(*this).myMovie = myMovie;
}
/*...................................................................*/
void QT::RedrawPoster()
{
PicHandle poster;
CWindowPtr moviePosterWindow;
GrafPtr oldPort;
Movie myMovie;
GetPort(&oldPort);
moviePosterWindow = (*this).moviePosterWindow;
myMovie = (*this).myMovie;
if (myMovie != NULL) {
poster = GetMoviePosterPict( myMovie );
if (poster != nil)
{
GrafPtr oldPort;
Rect rect;
GetPort(&oldPort);
SetPort(moviePosterWindow);
rect = (*moviePosterWindow).portRect;
//SetWindowPic( (WindowPtr)moviePosterWindow,poster);
//InsetRect( &rect, 3, 3 );
DrawPicture( poster, &rect );
KillPicture( poster );
SetPort(oldPort);
}
}
SetPort(oldPort);
}
/*...................................................................*/
/*...................................................................*/
/*...................................................................*/
/*...................................................................*/
/*...................................................................*/